import { defineStore } from 'pinia';
import * as merchantApi from '@/api/merchant';

export const useMerchantStore = defineStore('merchant', () => {
	async function getCategories(param?: any) {
		uni.showLoading();
		const response = await merchantApi.getCategories(param);
		uni.hideLoading();
		if (response.code === 20000) {
			return response.data.categories;
		}
		return [];
	}

	async function getMerchants(param?: any) {
		uni.showLoading();
		const response = await merchantApi.getMerchants(param);
		uni.hideLoading();
		if (response.code === 20000) {
			return response.data.merchants;
		}
		return [];
	}

	return {
		getCategories,
		getMerchants
	};
});
